{extend name="public/base"}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/admin/css/news.css" media="all" />
{/block}


{block name="main"}
<form class="layui-form" action="?" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">产品名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input newsName" name="name" value="{$data.name|default=''}" lay-verify="required" placeholder="请输入文章标题">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">产品标签</label>
            <div class="layui-input-block">
                <input type="checkbox" name="is_hot" value="1" {eq name="data.is_hot|default=''" value="1"} checked {/eq} title="热销">
                <input type="checkbox" name="is_recommend" value="1" {eq name="data.is_recommend|default=''" value="1"} checked {/eq} title="推荐">
                <input type="checkbox" name="is_sponsor" value="1" {eq name="data.is_sponsor|default=''" value="1"} checked {/eq} title="赞助">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input newsAuthor" placeholder="请输入排序" name="sort" value="{$data.sort|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">越大越靠前</div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">单位</label>
            <div class="layui-input-inline">
                <select name="unit" class="newsLook" lay-filter="unit" lay-verify="required">
                    <option value="">请选择</option>
                    <option value="瓶" {eq name="data.unit|default=''" value="瓶"} selected {/eq}>瓶</option>
                    <option value="箱" {eq name="data.unit|default=''" value="箱"} selected {/eq}>箱</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">香型</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input newsAuthor" placeholder="请输入香型" name="scent" value="{$data.scent|default=''}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">体积</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input newsAuthor" lay-verify="required" placeholder="请输入体积" name="ml" value="{$data.ml|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">单位（ml）</div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">度数</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" lay-verify="required" placeholder="请输入酒精含量" name="degree" value="{$data.degree|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">单位（%VOL）</div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">生产日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input newsTime" lay-verify="required|date" onclick="layui.laydate({elem:this})" placeholder="请选择" name="date_in_produced" value="{notempty name='data.date_in_produced'}{$data.date_in_produced|date='Y-m-d', ###}{/notempty}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">赞助人数</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" lay-verify="required" placeholder="活动人数大于该值才能申请" name="sponsor_num" value="{$data.sponsor_num|default=''}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">分类</label>
            <div class="layui-input-inline">
                <select name="category_id" class="newsLook" lay-filter="category_id" lay-verify="required">
                    <option value="">请选择</option>
                    {volist name="category" id="vo"}
                    <option value="{$vo.id}" {eq name="data.category_id|default=''" value="$vo.id"} selected {/eq}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">品牌</label>
            <div class="layui-input-inline">
                <select name="brand_id" class="newsLook" lay-filter="brand_id" lay-verify="required">
                    <option value="">请选择</option>
                    {volist name="brand" id="vo"}
                    <option value="{$vo.id}" {eq name="data.brand_id|default=''" value="$vo.id"} selected {/eq}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">价格</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" lay-verify="required" placeholder="请输入价格" name="price" value="{$data.price|default=''}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">柜台价</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" lay-verify="required" placeholder="请输入柜台价格" name="counter_price" value="{$data.counter_price|default=''}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">产地</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input newsName" lay-verify="required" placeholder="请输入产地" name="place_of_origin" value="{$data.place_of_origin|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">产品详情</label>
        <div class="layui-input-block">
            <textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="content">{notempty name="data.details"}{$data->details->content}{/notempty}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="send_form">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}

{block name="javascript"}
<script>
    layui.config({
        base : "js/"
    }).use(['form','layedit'],function() {
        var layedit = layui.layedit, form = layui.form();
        //创建一个编辑器
        layedit.set({
            uploadImage: {
                url: '{:url("base/upload_image", ["image_type" => 6])}', //接口url
            }
        });
        var editIndex = layedit.build('content');
        //自定义验证规则
        form.verify({
            content: function(value){
                layedit.sync(editIndex);
            }
        });
    });
</script>
{/block}